Memory Lecture Analysis: Stripping Away Abstractions
Hexadecimal Arithmetic & Physical Addressing
Memory is not an abstract infinite canvas, but a massive physical grid of hardware storage cells, each uniquely mapped by a discrete hexadecimal address. A single hex digit perfectly encapsulates 4 binary bits.
===================================================================================
BINARY TO HEXADECIMAL MEMORY ADDRESS MATRIX
===================================================================================
[ Binary Nibbles ] : 0111 1111 1111 1110 1110 0010 0011 0101 1000
[ Hex Address ] : 0x7 F F E E 2 3 5 8
===================================================================================
Pointers: The Bare-Metal Syntax Contract
A pointer is a specialized data type designed explicitly to store the absolute physical memory address of another variable. & extracts the address, while * dereferences it to access the payload.
Dynamic Heap Allocation (Malloc & Free)
The process memory layout bifurcates into the Stack (static call frames) and the Heap (dynamic runtime requests). Every block provisioned via Malloc must be explicitly freed to prevent fatal Memory Leaks.
===================================================================================
THE PROCESS MEMORY LAYOUT (STACK VS. HEAP DYNAMICS)
===================================================================================
[ High Memory 0xFFFFFFFF ]
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STACK ββ> Grows downward (Local variables & functions) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β β
β βΌ [ VIRTUAL FREE SPACE ] β
β β² β
β β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β HEAP ββ> Grows upward (Dynamic malloc requests) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BSS / DATA / TEXT (Compiled Binary & Static Variables) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
[ Low Memory 0x00000000 ]
===================================================================================